﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Microsoft.Win32.SafeHandles;

namespace JasLib.Interop.Win32
{
    public static partial class WININET
    {
        /// <param name="lpBuffer">
        /// Pointer to a buffer that receives the option setting.
        /// Strings returned by InternetQueryOption are globally allocated,
        /// so the calling application must free them when it is finished using them.
        /// </param>
        [DllImport(Constants.ModuleNames.WININET, EntryPoint = "InternetQueryOptionW", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern bool InternetQueryOption(
            [In] HINTERNET hInternet,
            [In] InternetOption dwOption,
            [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] lpBuffer,
            [In, Out] ref uint lpdwBufferLength);

        [DllImport(Constants.ModuleNames.WININET, EntryPoint = "InternetSetOptionW", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern bool InternetSetOption(
            [In] HINTERNET hInternet,
            [In] InternetOption dwOption,
            [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] lpBuffer,
            [In] uint dwBufferLength);
    }
}
